# -*- coding: utf-8 -*-
"""
author:码同学 极光
date:2024/3/17
desc: 
sample: 
"""
def func(a1):
    return 1,2,"，mtx"
result = func(1)
print(type(result))
for c1 in func(1):
    print(c1)

#仿强类型
def demo(name: str, age:int)->str:
   if  isinstance(age,int):
      age=age+1
   print(f"name {name},age {age}")
   return '1'

print(demo(1, 2))
print(demo(1, "1"))

def func(a1,a2):
    return a1 + a2
print("lambda----------")
funlambda = lambda a1,a2:a1 + a2
print(funlambda(1,2))

print("函数业务组合")
#set dict
test = [{'caseName': '测试1', 'order': 2,'开启':'是'}, {'caseName': '测试2', 'order': 1,'开启':'是'},
        {'caseName': '测试3', 'order': 4,'开启':'否'},{'caseName': '测试4', 'order': 3,'开启':'是'}]

#自定义过滤
test_filter_list = []
for item in test:
    if item['开启']=='是':
        test_filter_list.append(item)
print(test_filter_list)
print("-------------------")
test_filter_list = []
def myfilter(item):
    return item['开启']=='是'

test_filter_list = list(filter(myfilter,test))
print(test_filter_list)

print("-------------------lambda ")
test_filter_list2 = list(filter(lambda item: item["开启"] == "是",test))
print(test_filter_list2)

#排序
print("排序")
def takeOrder(item):
    return item['order']
test_filter_list.sort(key=takeOrder)
print(test_filter_list)

test_filter_list2.sort(key=lambda item: item['order'],reverse=True)
print(test_filter_list2)



